//
//  MOS6510Opcodes.h
//  C64
//
//  Created by Antonio "Willy" Malara on 19/04/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

typedef enum {
	MOS6510AddressingModeImplied,
	MOS6510AddressingModeAbsolute,
	MOS6510AddressingModeIndexedAbsolute,
	MOS6510AddressingModeIndexedZeroPage,
	MOS6510AddressingModeRelative,
	MOS6510AddressingModeAccumulator,
	MOS6510AddressingModeIndirectX,
	MOS6510AddressingModeIndirectY,
	MOS6510AddressingModeImmediate,
	MOS6510AddressingModeAbsoluteX,
	MOS6510AddressingModeAbsoluteY
} MOS6510AddressingModes;

typedef struct {
	char                   name[4];
	int                    cpuCycles;
	MOS6510AddressingModes mode;
} MOS6510Opcode;

MOS6510Opcode opcodeTable[0x100] =
{
/* 00 */ {"BRK", 7, MOS6510AddressingModeImplied},
/* 01 */ {"ORA", 6, MOS6510AddressingModeIndirectX},
/* 02 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 03 */ {"PHP", 3, MOS6510AddressingModeImplied},
/* 04 */ {"STY", 4, MOS6510AddressingModeImmediate},//z Page X
/* 05 */ {"ORA", 3, MOS6510AddressingModeIndexedZeroPage},
/* 06 */ {"ASL", 5, MOS6510AddressingModeIndexedZeroPage},
/* 07 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 08 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 09 */ {"ORA", 2, MOS6510AddressingModeImmediate},
/* 0A */ {"ASL", 2, MOS6510AddressingModeAccumulator},
/* 0B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 0C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 0D */ {"ORA", 4, MOS6510AddressingModeAbsolute},
/* 0E */ {"ASL", 6, MOS6510AddressingModeAbsolute},
/* 0F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 10 */ {"BPL", 2, MOS6510AddressingModeRelative},
/* 11 */ {"ORA", 5, MOS6510AddressingModeImmediate}, //Ind y
/* 12 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 13 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 14 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 15 */ {"ORA", 4, MOS6510AddressingModeImmediate}, //z Page X
/* 16 */ {"ASL", 6, MOS6510AddressingModeImmediate}, //z Page X
/* 17 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 18 */ {"CLC", 2, MOS6510AddressingModeImplied},
/* 19 */ {"ORA", 4, MOS6510AddressingModeImmediate}, // abs y
/* 1A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 1B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 1C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 1D */ {"ORA", 4, MOS6510AddressingModeImmediate}, // abs x
/* 1E */ {"ASL", 7, MOS6510AddressingModeImmediate}, // abs x
/* 1F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 20 */ {"JSR", 6, MOS6510AddressingModeAbsolute },
/* 21 */ {"AND", 6, MOS6510AddressingModeIndirectX},
/* 22 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 23 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 24 */ {"BIT", 3, MOS6510AddressingModeIndexedZeroPage},
/* 25 */ {"AND", 3, MOS6510AddressingModeIndexedZeroPage},
/* 26 */ {"ROL", 5, MOS6510AddressingModeIndexedZeroPage},
/* 27 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 28 */ {"PLF", 4, MOS6510AddressingModeImplied},
/* 29 */ {"AND", 2, MOS6510AddressingModeImmediate},
/* 2A */ {"ROL", 2, MOS6510AddressingModeAccumulator},
/* 2B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 2C */ {"BIT", 4, MOS6510AddressingModeIndexedAbsolute},
/* 2D */ {"AND", 4, MOS6510AddressingModeAbsolute},
/* 2E */ {"ROL", 6, MOS6510AddressingModeAbsolute},
/* 2F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 30 */ {"BMI", 2, MOS6510AddressingModeRelative}, //relative
/* 31 */ {"AND", 5, MOS6510AddressingModeIndirectY},
/* 32 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 33 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 34 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 35 */ {"AND", 4, MOS6510AddressingModeImmediate},//z page x
/* 36 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 37 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 38 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 39 */ {"AND", 4, MOS6510AddressingModeImmediate},//Abs y
/* 3A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 3B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 3C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 3D */ {"AND", 4, MOS6510AddressingModeAbsoluteX},
/* 3E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 3F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 40 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 41 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 42 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 43 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 44 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 45 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 46 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 47 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 48 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 49 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 4A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 4B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 4C */ {"JMP", 3, MOS6510AddressingModeAbsolute},
/* 4D */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 4E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 4F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 50 */ {"DVC", 2, MOS6510AddressingModeRelative},
/* 51 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 52 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 53 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 54 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 55 */ {"ADC", 3, MOS6510AddressingModeIndexedZeroPage},
/* 56 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 57 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 58 */ {"CLI", 2, MOS6510AddressingModeImplied},
/* 59 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5D */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 5F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 60 */ {"RTS", 0, MOS6510AddressingModeImplied},
/* 61 */ {"ADC", 6, MOS6510AddressingModeIndirectX},
/* 62 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 63 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 64 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 65 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 66 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 67 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 68 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 69 */ {"ADC", 2, MOS6510AddressingModeImmediate},
/* 6A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 6B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 6C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 6D */ {"ADC", 4, MOS6510AddressingModeAbsolute},
/* 6E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 6F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 70 */ {"BVS", 2, MOS6510AddressingModeRelative},
/* 71 */ {"ADC", 5, MOS6510AddressingModeIndirectY},
/* 72 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 73 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 74 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 75 */ {"ADC", 4, MOS6510AddressingModeImmediate},// z page x
/* 76 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 77 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 78 */ {"SEI", 2, MOS6510AddressingModeImplied},
/* 79 */ {"ADC", 4, MOS6510AddressingModeAbsoluteX},
/* 7A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 7B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 7C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 7D */ {"ADC", 4, MOS6510AddressingModeAbsoluteX},
/* 7E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 7F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 80 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 81 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 82 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 83 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 84 */ {"STY", 3, MOS6510AddressingModeIndexedZeroPage},
/* 85 */ {"STA", 3, MOS6510AddressingModeIndexedZeroPage},
/* 86 */ {"STX", 3, MOS6510AddressingModeIndexedZeroPage},
/* 87 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 88 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 89 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 8A */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 8B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 8C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 8D */ {"STA", 4, MOS6510AddressingModeAbsolute},
/* 8E */ {"STX", 4, MOS6510AddressingModeAbsolute},
/* 8F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 90 */ {"BCC", 2, MOS6510AddressingModeRelative},
/* 91 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 92 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 93 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 94 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 95 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 96 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 97 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 98 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 99 */ {"STA", 0, MOS6510AddressingModeAbsoluteY},
/* 9A */ {"TXS", 2, MOS6510AddressingModeImplied},
/* 9B */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 9C */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 9D */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 9E */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* 9F */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A0 */ {"LDY", 2, MOS6510AddressingModeImmediate},
/* A1 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A2 */ {"LDX", 2, MOS6510AddressingModeImmediate},
/* A3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A5 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A6 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* A8 */ {"TAY", 2, MOS6510AddressingModeImplied},
/* A9 */ {"LDA", 2, MOS6510AddressingModeImmediate},
/* AA */ {"TAX", 2, MOS6510AddressingModeImplied},
/* AB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* AC */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* AD */ {"LDA", 4, MOS6510AddressingModeAbsolute},
/* AE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* AF */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B0 */ {"BCS", 2, MOS6510AddressingModeRelative},
/* B1 */ {"LDA", 5, MOS6510AddressingModeIndirectY},
/* B2 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B5 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B6 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B8 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* B9 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* BA */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* BB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* BC */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* BD */ {"LDA", 4, MOS6510AddressingModeAbsoluteX},
/* BE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* BF */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C0 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C1 */ {"CMP", 6, MOS6510AddressingModeIndirectX},
/* C2 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C5 */ {"CMP", 3, MOS6510AddressingModeIndexedZeroPage},
/* C6 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* C8 */ {"INY", 2, MOS6510AddressingModeImplied},
/* C9 */ {"CMP", 2, MOS6510AddressingModeImmediate},
/* CA */ {"DEX", 2, MOS6510AddressingModeImplied},
/* CB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* CC */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* CD */ {"CMP", 4, MOS6510AddressingModeAbsolute},
/* CE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* CF */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D0 */ {"BNE", 2, MOS6510AddressingModeRelative},
/* D1 */ {"CMP", 5, MOS6510AddressingModeIndirectY},
/* D2 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D5 */ {"CMP", 4, MOS6510AddressingModeImmediate},//z page x
/* D6 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* D8 */ {"CLD", 2, MOS6510AddressingModeImplied},
/* D9 */ {"CMP", 4, MOS6510AddressingModeImmediate},//ala y
/* DA */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* DB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* DC */ {"NOP", 0, MOS6510AddressingModeAbsoluteX},
/* DD */ {"CMP", 4, MOS6510AddressingModeAbsoluteX},
/* DE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* DF */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E0 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E1 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E2 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E5 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E6 */ {"INC", 5, MOS6510AddressingModeIndexedZeroPage},
/* E7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E8 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* E9 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* EA */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* EB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* EC */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* ED */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* EE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* EF */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F0 */ {"BEQ", 2, MOS6510AddressingModeRelative},
/* F1 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F2 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F3 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F4 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F5 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F6 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F7 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F8 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* F9 */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FA */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FB */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FC */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FD */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FE */ {"NOP", 0, MOS6510AddressingModeImmediate},
/* FF */ {"NOP", 0, MOS6510AddressingModeImmediate},
};